import axios from '../../http/axios'
import {get} from '../../http/axios'

export default {
    //命名空间
    namespaced:true,
    //状态->data
    state:{
        dataList:{}
    },
    //过滤器->处理state中的变量
    getters:{
        confirmed(state){
            if(state.dataList.list)
            {
                var res = 0;
                state.dataList.list.forEach((item)=>{
                    res += item.confirmed;
            });
            return res;
            }
        },
        suspected(state){
            if(state.dataList.list)
            {
                var res = 0;
                state.dataList.list.forEach((item)=>{
                    res += itemm.suspected;
            });
            return res;
            }
        }
    },
    //突变->改变state中变量值的唯一方式
    mutations:{
        set_dataList(state,dataList){
            state.dataList = dataList;
        }
    },
    //动作->methods,发送请求
    actions:{
        async page_query(context,params){
            let res = await get('/epidemic/pageQuery',params);
            context.commit('set_dataList',res.data)
        }
    }
}